import json
import pickle
import inspect
from django.core.cache import cache

from testview.settings import OUT_TIME_DEL
from testviewset.models import User


def setToken(token, obj):
    state = cache.set(token, pickle.dumps(obj))
    cache.expire(token, OUT_TIME_DEL)
    # print(state)
    return state


def getTokenUser(token):


    obj = cache.get(token)
    if obj:
        return pickle.loads(obj)
    else:
        return None


def delToken(token):
    cache.delete(token)




